package com.systemic.vo;

import org.springframework.util.StringUtils;

/**
 * @ClassName: ImageVo
 * @Description:
 * @Author:
 * @CreateTime: 2023-12-28 11:09
 * @Version:
 **/
public class ImageVo {

    private Integer error;  // 检查图片上传是否有误 0表示上传正确 1表示失败
    private String url;
    private Integer width;
    private Integer height;

    public static ImageVo fail() {
        return new ImageVo(1, null, null, null);
    }

    public static ImageVo success(String url, Integer width, Integer height) {
        if (StringUtils.isEmpty(url) || width == null || width <= 0 || height == null || height <= 0) {
            return ImageVo.fail();
        }
        return new ImageVo(0, url, width, height);
    }

    public ImageVo() {
    }

    public ImageVo(Integer error, String url, Integer width, Integer height) {
        this.error = error;
        this.url = url;
        this.width = width;
        this.height = height;
    }

    public Integer getError() {
        return error;
    }

    public void setError(Integer error) {
        this.error = error;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Integer getWidth() {
        return width;
    }

    public void setWidth(Integer width) {
        this.width = width;
    }

    public Integer getHeight() {
        return height;
    }

    public void setHeight(Integer height) {
        this.height = height;
    }

    @Override
    public String toString() {
        return "ImageVo{" +
                "error=" + error +
                ", url='" + url + '\'' +
                ", width=" + width +
                ", height=" + height +
                '}';
    }
}
